//
//  detailProfile.m
//  HappyStore
//
//  Created by 陈锋 on 16/6/7.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "detailProfile.h"
#import "educationView.h"//教育经历
#import "workExpView.h"//工作经历
#import "detailProfileCell.h"
#import "addJobVC.h"
#import "hobbyVC.h"
#import "companyProfileVC.h"
#import "My_LiShuZuZhi.h"
#import "personAlproFile.h"
#import "BusinessNeeds.h"
#import "AreasConcern.h"
@interface detailProfile ()<UIActionSheetDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate,selectedAddressDelegate>{
    UIImageView * headImg;
    UIImage *imgUserHeaderImg;//用户头像
    NSArray *xingZhiArr;//企业性质
    NSArray *hangYeArr;//所属行业
    NSArray *guiMoArr;//公司规模
    
    NSMutableDictionary * dicNoti;
    NSString *personAlpro;
}

@property (strong, nonatomic) NSArray * labelArr;
@end

static NSString *detailProfilecell = @"detailProfileCell";
@implementation detailProfile

-(NSMutableArray *)workArr{
    if (!_workArr) {
        _workArr = [NSMutableArray array];
    }
    return _workArr;
}
-(NSMutableArray *)eduArr{
    if (!_eduArr) {
        _eduArr = [NSMutableArray array];
    }
    return _eduArr;
}
-(NSArray *)labelArr{
    if (!_labelArr) {
        if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 1) {//个人
            
            _labelArr = @[@"头像",@"*姓名",@"性别",@"年龄",@"*公司",@"职位",@"*工作城市",@"*关注领域",@"*商务需求",@"手机",@"邮箱",@"个人简介",@"兴趣爱好"];
        }else if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 2) {//企业
            
            _labelArr = @[@"头像",@"*公司名称",@"手机",@"邮箱",@"*公司性质",@"*所属行业",@"*公司规模",@"*公司地址",@"*关注领域",@"*商务需求",@"公司网址",@"企业简介"];
            
        }
    }
    return _labelArr;
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.translucent = NO;
    self.tabBarController.tabBar.hidden = YES;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"白色背景"] forBarMetrics:UIBarMetricsDefault];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 190, 44)];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.font = [UIFont systemFontOfSize:19];
    titleLabel.text = @"编辑资料";
    titleLabel.textColor = RGB(45, 45, 45);
    titleLabel.textAlignment = NSTextAlignmentCenter;
    self.navigationItem.titleView = titleLabel;
    
    xingZhiArr = @[@"民营",@"国有企业",@"合资",@"外资",@"事业单位",@"非盈利机构",@"其他"];
    hangYeArr = @[@"生物医药", @"旅游休闲", @"制造业", @"批发零售", @"房地产业", @"交通运输", @"冶金矿产",
                  @"建筑建材", @"信息软件", @"金融", @"教育", @"现代服务业", @"生态环保", @"市政基建", @"文体娱乐",
                  @"社会保障", @"水电燃气", @"农林牧渔", @"其他"];
    guiMoArr = @[@"50人以下",@"51-100人",@"101-500人",@"501-1000人",@"1000人以上"];
    
    // 注册
    UINib * nib = [UINib nibWithNibName:@"detailProfileCell" bundle:nil];
    [self.tableView registerNib:nib forCellReuseIdentifier:detailProfilecell];
    
    //设置返回按钮
    UIBarButtonItem *leftItem = [UIBarButtonItem itemWithTarget:self action:@selector(leftBarButtonItemClick) image:@"返回" highImage:@"返回"];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtonItemClick)];
    rightItem.tintColor = RGB(45, 45, 45);
    self.navigationItem.rightBarButtonItem = rightItem;
    //监听个人简介
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(personAlproFileText:) name:@"personAlproFileTextViewText" object:nil];
    //监听商务需求
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(businessNeedsText:) name:@"businessNeedsTextViewText" object:nil];
    //监听关注领域
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(areasConcernStr:) name:@"AreasConcernStr" object:nil];
    //取消返回的文字
    UIBarButtonItem *barButtionItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    self.navigationItem.backBarButtonItem = barButtionItem;
    
    //尾视图
    UIView * footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screenW, 44)];
    footView.backgroundColor = [UIColor colorWithRed:247.0/255.0 green:247.0/255.0 blue:247.0/255.0 alpha:1];
    UILabel * footLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, 150, 34)];
    footLabel.textColor = [UIColor lightGrayColor];
    footLabel.backgroundColor = [UIColor clearColor];
    footLabel.text = @"带*为必填项";
    footLabel.font = [UIFont systemFontOfSize:12.0];
    [footView addSubview:footLabel];
    self.tableView.tableFooterView = footView;
    
    //开启侧滑
    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
}
//商务需求
- (void)businessNeedsText:(NSNotification *)noti{
    NSMutableDictionary *mudic = [NSMutableDictionary dictionaryWithDictionary:noti.userInfo];
    
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 1) {
        [muDicParameters setObject:mudic[@"string"] forKey:@"myneeds"];//资源类型
        [self startEditeUserInfoWithDic:muDicParameters withType:8];
    }else{
    
        [muDicParameters setObject:mudic[@"string"] forKey:@"companyBusNeeds"];//资源类型
        [self startEditeUserInfoWithDic:muDicParameters withType:9];
    }
    
}
//个人简介
-(void)personAlproFileText:(NSNotification *)noti{
    NSMutableDictionary *muAlproFileText = [NSMutableDictionary dictionaryWithDictionary:noti.userInfo];
     personAlpro = muAlproFileText[@"string"];
    //[self title:@"个人简介" placeholedr:@"请输入您的个人简介" key:@"signature" type:11]
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:personAlpro forKey:@"signature"];//资源类型
    
    [self startEditeUserInfoWithDic:muDicParameters withType:11];
}


//关注领域
- (void)areasConcernStr:(NSNotification *)noti{
    NSDictionary * mudic = [NSDictionary dictionaryWithDictionary:noti.userInfo];
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 1) {
        [muDicParameters setObject:mudic[@"string"] forKey:@"goodatfield"];//资源类型
        [self startEditeUserInfoWithDic:muDicParameters withType:7];
    }else{
        
        [muDicParameters setObject:mudic[@"string"] forKey:@"companyField"];//资源类型
        [self startEditeUserInfoWithDic:muDicParameters withType:8];
    }
}


-(void)rightBarButtonItemClick{

    [self showRightWithTitle:@"保存成功!" autoCloseTime:2];
    
    [self.navigationController popViewControllerAnimated:YES];
    
    
}
-(void)leftBarButtonItemClick{
    
    [self.navigationController popViewControllerAnimated:YES];
  
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    if (section == 0) {
        return 4;
    }else if (section == 1){
        if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 1) {//个人
            
            return 9;
            
        }else if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 2) {//企业
            
            return 8;
            
        }else return 0;
        
    }else return 0;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    detailProfileCell * detailProfileCell = [self.tableView dequeueReusableCellWithIdentifier:detailProfilecell];

    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 1) {//个人
        
        if (indexPath.section == 0) {
            detailProfileCell.leftLabel.text = self.labelArr[indexPath.row];
            detailProfileCell.leftLabel.textColor = [UIColor lightGrayColor];
            
            if (indexPath.row == 0) {
                detailProfileCell.rightLabel.hidden = YES;
                detailProfileCell.headImg.hidden = NO;
                headImg = detailProfileCell.headImg;
                [headImg.layer setCornerRadius:(headImg.frame.size.height/2)];
                [headImg.layer setMasksToBounds:YES];
                [headImg setContentMode:UIViewContentModeScaleAspectFill];
                [headImg setClipsToBounds:YES];
                headImg.layer.shadowColor = [UIColor whiteColor].CGColor;
                headImg.layer.shadowOffset = CGSizeMake(4, 4);
                headImg.layer.shadowOpacity = 0.5;
                headImg.layer.shadowRadius = 2.0;
                [headImg sd_setImageWithURL:[NSURL URLWithString:self.dataDict[@"headPhoto"]] placeholderImage:[UIImage imageNamed:@"logo"]];
                
            }else{
                detailProfileCell.headImg.hidden = YES;
                detailProfileCell.rightLabel.hidden = NO;
                switch (indexPath.row) {
                        
                    case 1:
                        if ([self.dataDict[@"userName"] isEqualToString:@""] || [self.dataDict[@"userName"] isEqualToString:@"null"]) {
                            detailProfileCell.rightLabel.text = @"请添加";
                        }else{
                            detailProfileCell.rightLabel.text = self.dataDict[@"userName"];
                        }
                        break;
                        
                    case 2:
                        if ([self.dataDict[@"sex"] isEqualToString:@""] || [self.dataDict[@"sex"] isEqualToString:@"null"]) {
                            detailProfileCell.rightLabel.text = @"请选择";
                        }else{
                            detailProfileCell.rightLabel.text = self.dataDict[@"sex"];
                        }
                        break;
                        
                    case 3:
                        if ([self.dataDict[@"age"] isEqualToString:@""] || [self.dataDict[@"age"] isEqualToString:@"null"]) {
                            detailProfileCell.rightLabel.text = @"请填写";
                        }else{
                            detailProfileCell.rightLabel.text = self.dataDict[@"age"];
                        }
                        break;
                        
                    default:
                        break;
                }
            }
        }else if (indexPath.section == 1){
            detailProfileCell.leftLabel.text = self.labelArr[4 + indexPath.row];
            detailProfileCell.leftLabel.textColor = [UIColor lightGrayColor];
            detailProfileCell.headImg.hidden = YES;
            detailProfileCell.rightLabel.hidden = NO;
            switch (indexPath.row) {
                case 0:
                    
                    if (dicNoti) {
                        detailProfileCell.rightLabel.text = dicNoti[@"username"];
                    }else{
                    
                    if ([self.dataDict[@"companyName"] isEqualToString:@""] || [self.dataDict[@"companyName"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请填写";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"companyName"];
                    }
                    }
                    break;
                    
                case 1:
                    if ([self.dataDict[@"positionName"] isEqualToString:@""] || [self.dataDict[@"positionName"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请填写";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"positionName"];
                    }
                    break;
                    
                case 2:
                    if ([self.dataDict[@"address"] isEqualToString:@""] || [self.dataDict[@"address"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请添加";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"address"];
                    }
                    break;
                    
                case 3:
                    if ([self.dataDict[@"goodatfield"] isEqualToString:@""] || [self.dataDict[@"goodatfield"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请添加";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"goodatfield"];
                    }
                    break;
                    
                case 4:
                    if ([self.dataDict[@"myneeds"] isEqualToString:@""] || [self.dataDict[@"myneeds"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请添加";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"myneeds"];
                    }
                    break;
                    
                case 5:
                    if ([self.dataDict[@"mobile"] isEqualToString:@""] || [self.dataDict[@"mobile"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请添加";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"mobile"];
                    }
                    break;
                    
                case 6:
                    if ([self.dataDict[@"email"] isEqualToString:@""] || [self.dataDict[@"email"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请添加";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"email"];
                    }
                    break;
                case 7:
                    if ([self.dataDict[@"signature"] isEqualToString:@""] || [self.dataDict[@"signature"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请添加";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"signature"];
                    }
                    break;
                    
                case 8:
                    detailProfileCell.rightLabel.text = @"";
                    break;
                default:
                    break;
            }
        }
        
        return detailProfileCell;

        
    }else if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 2) {//企业
        
        if (indexPath.section == 0) {
            detailProfileCell.leftLabel.text = self.labelArr[indexPath.row];
            detailProfileCell.leftLabel.textColor = [UIColor lightGrayColor];
            
            if (indexPath.row == 0) {
                detailProfileCell.rightLabel.hidden = YES;
                detailProfileCell.headImg.hidden = NO;
                headImg = detailProfileCell.headImg;
                [headImg sd_setImageWithURL:[NSURL URLWithString:self.dataDict[@"headPhoto"]] placeholderImage:[UIImage imageNamed:@"logo"]];
                [headImg.layer setCornerRadius:(headImg.frame.size.height/2)];
                [headImg.layer setMasksToBounds:YES];
                [headImg setContentMode:UIViewContentModeScaleAspectFill];
                [headImg setClipsToBounds:YES];
                headImg.layer.shadowColor = [UIColor whiteColor].CGColor;
                headImg.layer.shadowOffset = CGSizeMake(4, 4);
                headImg.layer.shadowOpacity = 0.5;
                headImg.layer.shadowRadius = 2.0;
                
                
            }else{
                detailProfileCell.headImg.hidden = YES;
                detailProfileCell.rightLabel.hidden = NO;
                switch (indexPath.row) {
                        
                    case 1:
                        if ([self.dataDict[@"userName"] isEqualToString:@""] || [self.dataDict[@"userName"] isEqualToString:@"null"]) {
                            detailProfileCell.rightLabel.text = @"请添加";
                        }else{
                            detailProfileCell.rightLabel.text = self.dataDict[@"userName"];
                        }
                        break;
                        
                    case 2:
                        if ([self.dataDict[@"mobile"] isEqualToString:@""] || [self.dataDict[@"mobile"] isEqualToString:@"null"]) {
                            detailProfileCell.rightLabel.text = @"请添加";
                        }else{
                            detailProfileCell.rightLabel.text = self.dataDict[@"mobile"];
                        }
                        break;
                        
                    case 3:
                        if ([self.dataDict[@"email"] isEqualToString:@""] || [self.dataDict[@"email"] isEqualToString:@"null"]) {
                            detailProfileCell.rightLabel.text = @"请填写";
                        }else{
                            detailProfileCell.rightLabel.text = self.dataDict[@"email"];
                        }
                        break;
                        
                    default:
                        break;
                }
            }
        }else if (indexPath.section == 1){
            detailProfileCell.leftLabel.text = self.labelArr[4 + indexPath.row];
            detailProfileCell.leftLabel.textColor = [UIColor lightGrayColor];
            detailProfileCell.headImg.hidden = YES;
            detailProfileCell.rightLabel.hidden = NO;
            switch (indexPath.row) {
                case 0:
                    if ([self.dataDict[@"companyNature"] isEqualToString:@""] || [self.dataDict[@"companyNature"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请选择";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"companyNature"];
                    }
                    break;
                    
                case 1:
                    if ([self.dataDict[@"companyIndustry"] isEqualToString:@""] || [self.dataDict[@"companyIndustry"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请选择";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"companyIndustry"];
                    }
                    break;
                    
                case 2:
                    if ([self.dataDict[@"companyScale"] isEqualToString:@""] || [self.dataDict[@"companyScale"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请选择";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"companyScale"];
                    }
                    break;
                    
                case 3:
                    if ([self.dataDict[@"address"] isEqualToString:@""] || [self.dataDict[@"address"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请选择";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"address"];
                    }
                    break;
                    
                case 4:
                    if ([self.dataDict[@"companyField"] isEqualToString:@""] || [self.dataDict[@"companyField"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请选择";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"companyField"];
                    }
                    break;
                    
                case 5:
                    if ([self.dataDict[@"companyBusNeeds"] isEqualToString:@""] || [self.dataDict[@"companyBusNeeds"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请添加";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"companyBusNeeds"];
                    }
                    break;
                    
                case 6:
                    if ([self.dataDict[@"companyWWW"] isEqualToString:@""] || [self.dataDict[@"companyWWW"] isEqualToString:@"null"]) {
                        detailProfileCell.rightLabel.text = @"请添加";
                    }else{
                        detailProfileCell.rightLabel.text = self.dataDict[@"companyWWW"];
                    }
                    break;
                case 7:
                    detailProfileCell.rightLabel.text = @"";
                    break;

                default:
                    break;
            }
        }
 
        return detailProfileCell;
        
    }else return nil;
    
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];//取消选中状态
    
    if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 1) {//个人
        
        if (indexPath.section == 0) {
            if (indexPath.row == 0) {
                UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"照片选择"
                                                                         delegate:self
                                                                cancelButtonTitle:@"取消"
                                                           destructiveButtonTitle:nil
                                                                otherButtonTitles:@"相机",@"相册", nil];
                
                actionSheet.tag = 200;
                [actionSheet showInView:self.view];
                
            }else if (indexPath.row ==1){
                
                [self title:@"用户昵称" placeholedr:@"请输入您的昵称" key:@"userName" type:1];
                
            }else if (indexPath.row == 2){
                
                UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"性别选择"
                                                                         delegate:self
                                                                cancelButtonTitle:@"取消"
                                                           destructiveButtonTitle:nil
                                                                otherButtonTitles:@"男",@"女", nil];
                actionSheet.tag = 100;
                [actionSheet showInView:self.view];
                
                
            }else if (indexPath.row == 3){
                
                [self title:@"年龄" placeholedr:@"请输入您的年龄" key:@"age" type:3];
            }
            
        }else if (indexPath.section == 1){
            
            if (indexPath.row == 0) {
                
                [self title:@"公司名称" placeholedr:@"请输入您的公司名称" key:@"companyName" type:4];
//            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setLiShuZuzhi:) name:@"setLiShuZuzhi" object:nil];
//                UIStoryboard *sb=[UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
//                
//                My_LiShuZuZhi * searchVC = [sb instantiateViewControllerWithIdentifier:@"mylishuzuzhi"];
//                
//                
//                [self.navigationController pushViewController:searchVC animated:YES];
//                
                
            }else if (indexPath.row == 1){
                
                [self title:@"职位" placeholedr:@"请输入您的职位" key:@"positionName" type:5];
                
            }else if (indexPath.row == 2){
                
                SelectedAddress *selectAddress = [SelectedAddress sharedSelectedAddress];
                selectAddress.delegatee = self;
                [selectAddress btnClickAddress];
                
            }else if (indexPath.row == 3){
                
//                UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"关注领域"
//                                                                         delegate:self
//                                                                cancelButtonTitle:@"取消"
//                                                           destructiveButtonTitle:nil
//                                                                otherButtonTitles:@"生物医药", @"旅游休闲", @"制造业", @"批发零售", @"房地产业", @"交通运输", @"冶金矿产",
//                                              @"建筑建材", @"信息软件", @"金融", @"教育", @"现代服务业", @"生态环保", @"市政基建", @"文体娱乐",
//                                              @"社会保障", @"水电燃气", @"农林牧渔", @"其他", nil];
//                
//                actionSheet.tag = 600;
//                [actionSheet showInView:self.view];
                
                AreasConcern *areasConcernVC = [[AreasConcern alloc] init];
                areasConcernVC.titleString = @"关注领域";
                [self.navigationController pushViewController:areasConcernVC animated:YES];
                
            }else if (indexPath.row == 4){
                
                //[self title:@"商务需求" placeholedr:@"请输入您的商务需求" key:@"myneeds" type:8];
                BusinessNeeds *needVC = [[BusinessNeeds alloc] initWithNibName:@"BusinessNeeds" bundle:nil];
                needVC.needStr = self.dataDict[@"myneeds"];
                [self.navigationController pushViewController:needVC animated:YES];
                
            }else if (indexPath.row == 5){
                
                [self title:@"联系电话" placeholedr:@"请输入您的联系电话" key:@"mobile" type:9];
                
            }else if (indexPath.row == 6){
                
                [self title:@"邮箱地址" placeholedr:@"请输入您的邮箱" key:@"email" type:10];
                
            }else if (indexPath.row == 7){
                
                //[self title:@"个人简介" placeholedr:@"请输入您的个人简介" key:@"signature" type:11];
               
                
                personAlproFile *personVC = [[personAlproFile alloc] initWithNibName:@"personAlproFile" bundle:nil];
                personVC.alproFileStr = self.dataDict[@"signature"];
                [self.navigationController pushViewController:personVC animated:YES];
                
                
            }else if (indexPath.row == 8){
                hobbyVC * hobby = [[hobbyVC alloc]init];
                
                NSString * str = self.dataDict[@"hobby"];
                NSMutableArray * arr = [[str componentsSeparatedByString:@","]copy];
                hobby.hobbyArr = [NSMutableArray arrayWithArray:arr];
                [hobby.hobbyArr removeLastObject];
                
                [self.navigationController pushViewController:hobby animated:YES];
            }
            
        }
        

        
    }else if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 2) {//企业
        
        if (indexPath.section == 0) {
            if (indexPath.row == 0) {
                UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"照片选择"
                                                                         delegate:self
                                                                cancelButtonTitle:@"取消"
                                                           destructiveButtonTitle:nil
                                                                otherButtonTitles:@"相机",@"相册", nil];
                
                actionSheet.tag = 200;
                [actionSheet showInView:self.view];
                
            }else if (indexPath.row ==1){
                
                [self title:@"用户昵称" placeholedr:@"请输入您的昵称" key:@"userName" type:1];
                
            }else if (indexPath.row == 2){
                
                [self title:@"联系电话" placeholedr:@"请输入您的联系电话" key:@"mobile" type:2];
                
                
            }else if (indexPath.row == 3){
                
                [self title:@"邮箱地址" placeholedr:@"请输入您的邮箱" key:@"email" type:3];
            }
            
        }else if (indexPath.section == 1){
            
            if (indexPath.row == 0) {
                
                UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"公司性质"
                                                                         delegate:self
                                                                cancelButtonTitle:@"取消"
                                                           destructiveButtonTitle:nil
                                                                otherButtonTitles:@"民营",@"国有企业",@"合资",@"外资",@"事业单位",@"非盈利机构",@"其他", nil];
                
                actionSheet.tag = 300;
                [actionSheet showInView:self.view];
                
            }else if (indexPath.row == 1){
                
                UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"所属行业"
                                                                         delegate:self
                                                                cancelButtonTitle:@"取消"
                                                           destructiveButtonTitle:nil
                                                                otherButtonTitles:@"生物医药", @"旅游休闲", @"制造业", @"批发零售", @"房地产业", @"交通运输", @"冶金矿产",
                                              @"建筑建材", @"信息软件", @"金融", @"教育", @"现代服务业", @"生态环保", @"市政基建", @"文体娱乐",
                                              @"社会保障", @"水电燃气", @"农林牧渔", @"其他", nil];
                
                actionSheet.tag = 400;
                [actionSheet showInView:self.view];
                
            }else if (indexPath.row == 2){
                
                UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"公司规模"
                                                                         delegate:self
                                                                cancelButtonTitle:@"取消"
                                                           destructiveButtonTitle:nil
                                                                otherButtonTitles:@"50人以下",@"51-100人",@"101-500人",@"501-1000人",@"1000人以上", nil];
                
                actionSheet.tag = 500;
                [actionSheet showInView:self.view];
                
            }else if (indexPath.row == 3){
                
                SelectedAddress *selectAddress = [SelectedAddress sharedSelectedAddress];
                selectAddress.delegatee = self;
                [selectAddress btnClickAddress];
                
            }else if (indexPath.row == 4){
                
//                UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"关注领域"
//                                                                         delegate:self
//                                                                cancelButtonTitle:@"取消"
//                                                           destructiveButtonTitle:nil
//                                                                otherButtonTitles:@"生物医药", @"旅游休闲", @"制造业", @"批发零售", @"房地产业", @"交通运输", @"冶金矿产",
//                                              @"建筑建材", @"信息软件", @"金融", @"教育", @"现代服务业", @"生态环保", @"市政基建", @"文体娱乐",
//                                              @"社会保障", @"水电燃气", @"农林牧渔", @"其他", nil];
//                
//                actionSheet.tag = 600;
//                [actionSheet showInView:self.view];
                AreasConcern *areasConcernVC = [[AreasConcern alloc] init];
                [self.navigationController pushViewController:areasConcernVC animated:YES];
            }else if (indexPath.row == 5){
                BusinessNeeds *needVC = [[BusinessNeeds alloc] initWithNibName:@"BusinessNeeds" bundle:nil];
                needVC.needStr = self.dataDict[@"companyBusNeeds"];
                [self.navigationController pushViewController:needVC animated:YES];
                //[self title:@"商务需求" placeholedr:@"请输入您的商务需求" key:@"companyBusNeeds" type:9];
                
            }else if (indexPath.row == 6){
                
                [self title:@"公司网址" placeholedr:@"请输入您的公司网址" key:@"companyWWW" type:10];
                
            }else if (indexPath.row == 7){
                
                companyProfileVC * profileVC = [[companyProfileVC alloc]init];
                
                //if (![self.dataDict[@"introduction"] isEqualToString:@""] || ![self.dataDict[@"introduction"] isEqualToString:@"null"]) {
                    
                    //profileVC.textView.text = self.dataDict[@"introduction"];
                    
                //}
                profileVC.textStr = self.dataDict[@"introduction"];
                [self.navigationController pushViewController:profileVC animated:YES];
            }
        }
  
    }
    
    }
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 44;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 0;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 30;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.tableView.width, 30)];
    view.backgroundColor = [UIColor colorWithRed:247.0/255.0 green:247.0/255.0 blue:247.0/255.0 alpha:1];
    UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(5, 2, 60, 25)];
    label.backgroundColor = [UIColor clearColor];
    label.textColor = [UIColor colorWithRed:0.0/255.0f green:180.0/255.0f blue:222.0/255.0f alpha:1.0f];
    label.font = [UIFont systemFontOfSize:14];
    
    if (section == 0) {
        label.text = @"基本资料";
        [view addSubview:label];
        return view;
        
    }else if (section == 1){
        label.text = @"商务资料";
        [view addSubview:label];
        return view;
        
    }else if (section == 2){
        label.text = @"详细资料";
        [view addSubview:label];
        return view;
    }
    else
        
        
        return nil;
}
#pragma mark - 选择照片
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    switch (actionSheet.tag) {
        case 100://性别
        {
            //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
            NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
            switch (buttonIndex) {
                case 0:
                {
                    [muDicParameters setObject:@"男" forKey:@"sex"];//性别
                    [self startEditeUserInfoWithDic:muDicParameters withType:2];
                }
                    break;
                case 1:
                {
                    [muDicParameters setObject:@"女" forKey:@"sex"];//性别
                    [self startEditeUserInfoWithDic:muDicParameters withType:2];
                }
                    break;
                case 2:
                {
                    //取消
                }
                    break;
                    
                default:
                    break;
            }
        }
            break;
        case 200://头像
        {
            //先设定sourceType为相机，然后判断相机是否可用（ipod）没相机，不可用将sourceType设定为相片库
            UIImagePickerController *pickerImage = [[UIImagePickerController alloc] init];
            pickerImage.delegate = self;
            pickerImage.allowsEditing = YES;//设置可编辑
            switch (buttonIndex) {
                case 0:
                {
                    NSLog(@"相机");
                    pickerImage.sourceType = UIImagePickerControllerSourceTypeCamera;
                    [self presentViewController:pickerImage animated:YES completion:nil];//进入照相界面
                }
                    break;
                case 1:
                {
                    NSLog(@"相册");
                    pickerImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //图片库
                    [self presentViewController:pickerImage animated:YES completion:nil];//进入照相界面
                }
                    break;
                case 2:
                {
                    NSLog(@"取消");
                }
                    break;
            }
        }
            break;
        case 300://性质
        {
            //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
            NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
            switch (buttonIndex) {
                case 0:
                {
                    [muDicParameters setObject:xingZhiArr[buttonIndex] forKey:@"companyNature"];//性质
                    [self startEditeUserInfoWithDic:muDicParameters withType:4];
                }
                    break;
                case 1:
                {
                    [muDicParameters setObject:xingZhiArr[buttonIndex] forKey:@"companyNature"];//性质
                    [self startEditeUserInfoWithDic:muDicParameters withType:4];
                }
                    break;
                case 2:
                {
                    [muDicParameters setObject:xingZhiArr[buttonIndex] forKey:@"companyNature"];//性质
                    [self startEditeUserInfoWithDic:muDicParameters withType:4];
                }
                    break;
                case 3:
                {
                    [muDicParameters setObject:xingZhiArr[buttonIndex] forKey:@"companyNature"];//性质
                    [self startEditeUserInfoWithDic:muDicParameters withType:4];
                }
                    break;
                case 4:
                {
                    [muDicParameters setObject:xingZhiArr[buttonIndex] forKey:@"companyNature"];//性质
                    [self startEditeUserInfoWithDic:muDicParameters withType:4];
                }
                    break;
                case 5:
                {
                    [muDicParameters setObject:xingZhiArr[buttonIndex] forKey:@"companyNature"];//性质
                    [self startEditeUserInfoWithDic:muDicParameters withType:4];
                }
                    break;
                case 6:
                {
                    [muDicParameters setObject:xingZhiArr[buttonIndex] forKey:@"companyNature"];//性质
                    [self startEditeUserInfoWithDic:muDicParameters withType:4];
                }
                    break;
                case 7:
                {
                    // 取消
                }
                    break;
                    
                default:
                    break;
            }
        }
            break;
            
        case 400://公司行业
        {
            //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
            NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
            switch (buttonIndex) {
                case 0:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 1:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 2:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 3:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 4:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 5:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 6:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 7:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 8:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 9:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 10:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 11:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 12:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 13:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 14:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 15:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 16:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 17:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 18:
                {
                    [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyIndustry"];//公司行业
                    [self startEditeUserInfoWithDic:muDicParameters withType:5];
                }
                    break;
                case 19:
                    // 取消
                    break;
                    
                default:
                    break;
            }
        }
            break;
            
        case 500://公司规模
        {
            //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
            NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
            switch (buttonIndex) {
                case 0:
                {
                    [muDicParameters setObject:guiMoArr[buttonIndex] forKey:@"companyScale"];//性质
                    [self startEditeUserInfoWithDic:muDicParameters withType:6];
                }
                    break;
                case 1:
                {
                    [muDicParameters setObject:guiMoArr[buttonIndex] forKey:@"companyScale"];//性质
                    [self startEditeUserInfoWithDic:muDicParameters withType:6];
                }
                    break;
                case 2:
                {
                    [muDicParameters setObject:guiMoArr[buttonIndex] forKey:@"companyScale"];//性质
                    [self startEditeUserInfoWithDic:muDicParameters withType:6];
                }
                    break;
                case 3:
                {
                    [muDicParameters setObject:guiMoArr[buttonIndex] forKey:@"companyScale"];//性质
                    [self startEditeUserInfoWithDic:muDicParameters withType:6];
                }
                    break;
                case 4:
                {
                    [muDicParameters setObject:guiMoArr[buttonIndex] forKey:@"companyScale"];//性质
                    [self startEditeUserInfoWithDic:muDicParameters withType:6];
                }
                    break;
                case 5:
                {
                    // 取消
                }
                    break;
                    
                default:
                    break;
            }
        }
            break;
            
        case 600://关注领域
        {
            //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
            NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
            if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 1) {//个人
                switch (buttonIndex) {
                    case 0:
                    {
//                        [self title:@"关注领域" placeholedr:@"请输入您关注的领域" key:@"goodatfield" type:7];
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 1:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 2:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 3:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 4:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 5:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 6:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 7:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 8:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 9:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 10:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 11:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 12:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 13:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 14:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 15:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 16:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 17:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 18:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"goodatfield"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:7];
                    }
                        break;
                    case 19:
                        // 取消
                        break;
                        
                    default:
                        break;
                }
                
            }else{
                switch (buttonIndex) {
                    case 0:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 1:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 2:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 3:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 4:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 5:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 6:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 7:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 8:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 9:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 10:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 11:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 12:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 13:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 14:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 15:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 16:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 17:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 18:
                    {
                        [muDicParameters setObject:hangYeArr[buttonIndex] forKey:@"companyField"];//关注领域
                        [self startEditeUserInfoWithDic:muDicParameters withType:8];
                    }
                        break;
                    case 19:
                        // 取消
                        break;
                        
                    default:
                        break;
                }
            }

        }
            break;
            
        default:
            break;
    }
    
    
    
}

//点击相册中的图片 货照相机照完后点击use  后触发的方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [picker dismissViewControllerAnimated:YES completion:^{}];
    
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
    //    [_btnUserImg setImage:image forState:UIControlStateNormal];
    //    _btnUserImg.layer.masksToBounds = YES;
    //    _btnUserImg.layer.cornerRadius = 20.0;
    /* 此处info 有六个值
     * UIImagePickerControllerMediaType; // an NSString UTTypeImage)
     * UIImagePickerControllerOriginalImage;  // a UIImage 原始图片
     * UIImagePickerControllerEditedImage;    // a UIImage 裁剪后图片
     */
    // 保存图片至本地，方法见下文
    //    NSString *strName = [NSString stringWithFormat:@"%@.jpg",[self dateString]];
    //    [self saveImage:image withName:strName];
    
    
    imgUserHeaderImg = image;
    
    [self startEditeHeaderImage];
}
#pragma mark - 开始上传头像
- (void)startEditeHeaderImage
{
    //token=rE3F2m8AvfC7CVh85O9q&userId=9 参数说明：photo-为图片
    
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
  
         NSString *strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"changePhoto_app_myHome.im.lensum"];
 
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    [manager POST:strURl parameters:muDicParameters constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        NSData *imageData = UIImageJPEGRepresentation(imgUserHeaderImg, 0.5);
        [formData appendPartWithFileData:imageData name:@"photo" fileName:@"photo.jpg" mimeType:@"image/jpeg"];
        
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
//        NSLog(@"%@",dicInfo);
        if ([dicInfo[@"result"] integerValue] == 1) {
            headImg.image = imgUserHeaderImg;
            [self.dataDict setObject:dicInfo[@"data"][0] forKey:@"headPhoto"];
            
            [USER_DEFAULTS setObject:self.dataDict[@"headPhoto"] forKey:@"headPhoto"];
            
            //刷新缓存
            RCUserInfo *userInfo = [RCUserInfo new];
            userInfo.userId = [USER_DEFAULTS objectForKey:@"account"];
            userInfo.name = _dataDict[@"userName"];
            userInfo.portraitUri = self.dataDict[@"headPhoto"];
            [[RCIM sharedRCIM] refreshUserInfoCache:userInfo
                                         withUserId:userInfo.userId];


        }else {

            [self showSingleIconBubble:dicInfo[@"msg"]];
            
        }
        
        [self hideBubble];

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

        [self showSingleIconBubble:error.localizedDescription];

    }];
    
}
#pragma mark - 所在地代理
- (void)seceltedRowSshowMsg:(NSString *)showMsg andProvince:(NSString *)strProvince andCity:(NSString *)strCity andDistrict:(NSString *)strDistrict
{
    //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:showMsg forKey:@"address"];//资源类型
    
    if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 1) {//个人
        
        [self startEditeUserInfoWithDic:muDicParameters withType:6];
        
    }else if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 2) {//企业
        
        [self startEditeUserInfoWithDic:muDicParameters withType:7];
        
    }
    
}
- (void)startEditeUserInfoWithDic:(NSDictionary *)dicc withType:(NSInteger)type
{
    //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
    
    NSString *strURl;
    
    if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 1) {//个人
        
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"updateUser_People_app_myHome.im.lensum"];
        
    }else if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 2) {//企业
        
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"updateUser_Company_app_myHome.im.lensum"];
    }
    
//    if (dicNoti) {
//        dicc = dicNoti;
//    }
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strURl parameters:dicc progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
//        NSLog(@"%@",dicInfo);
        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            
            if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 1) {//个人
                
                switch (type) {
                    case 1://修改用户名
                    {
                        [_dataDict setObject:dicc[@"userName"] forKey:@"userName"];
                        [self.tableView reloadData];
                    }
                        break;
                    case 2://性别
                    {
                        [_dataDict setObject:dicc[@"sex"] forKey:@"sex"];
                        [self.tableView reloadData];
                    }
                        break;
                    case 3://年龄
                    {
                        [_dataDict setObject:dicc[@"age"] forKey:@"age"];
                        [self.tableView reloadData];
                    }
                        break;
                    case 4://公司
                    {
                        [_dataDict setObject:dicc[@"companyName"] forKey:@"companyName"];
                        [self.tableView reloadData];
                    }
                        break;
                    case 5://职位
                    {
                        //                    NSString *str1 = @"";
                        //                    if (dicNoti[@"username"] == [NSNull null] || [dicNoti[@"username"] isEqualToString:@"null"]) {
                        //                        str1 = dicNoti[@"account"];
                        //                    }else {
                        //                        str1 = dicNoti[@"username"];
                        //                    }
                        //                    [muAryTitleContent replaceObjectAtIndex:3 withObject:str1];
                        [_dataDict setObject:dicc[@"positionName"] forKey:@"positionName"];
                        [self.tableView reloadData];
                    }
                        break;
                    case 6://所在地区
                    {
                        [_dataDict setObject:dicc[@"address"] forKey:@"address"];
                        [USER_DEFAULTS setObject:dicc[@"address"] forKey:@"address"];
                        [USER_DEFAULTS synchronize];
                        [self.tableView reloadData];
                    }
                        break;
                    case 7://关注的领域
                    {
                        [_dataDict setObject:dicc[@"goodatfield"] forKey:@"goodatfield"];
                        [USER_DEFAULTS setObject:dicc[@"goodatfield"] forKey:@"industry"];
                        [USER_DEFAULTS synchronize];
                        [self.tableView reloadData];
                    }
                        break;
                    case 8://商务需求
                    {
                        [_dataDict setObject:dicc[@"myneeds"] forKey:@"myneeds"];
                        [self.tableView reloadData];
                    }
                        break;
                        
                    case 9://联系电话
                    {
                        [_dataDict setObject:dicc[@"mobile"] forKey:@"mobile"];
                        [self.tableView reloadData];
                    }
                        break;
                        
                    case 10://邮箱地址
                    {
                        [_dataDict setObject:dicc[@"email"] forKey:@"email"];
                        [self.tableView reloadData];
                    }
                        break;
                        
                    case 11:
                    {
                        [_dataDict setObject:dicc[@"signature"] forKey:@"signature"];
                        [self.tableView reloadData];
                    }
                    default:
                        break;
                }

                
            }else if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 2) {//企业
                
                switch (type) {
                    case 1://修改用户名
                    {
                        [_dataDict setObject:dicc[@"userName"] forKey:@"userName"];
                        [self.tableView reloadData];
                    }
                        break;
                    case 2://电话
                    {
                        [_dataDict setObject:dicc[@"mobile"] forKey:@"mobile"];
                        [self.tableView reloadData];
                    }
                        break;
                    case 3://邮箱地址
                    {
                        [_dataDict setObject:dicc[@"email"] forKey:@"email"];
                        [self.tableView reloadData];
                    }
                        break;
                    case 4://公司性质
                    {
                        [_dataDict setObject:dicc[@"companyNature"] forKey:@"companyNature"];
                        [self.tableView reloadData];
                    }
                        break;
                    case 5://所属行业
                    {
                        //                    NSString *str1 = @"";
                        //                    if (dicNoti[@"username"] == [NSNull null] || [dicNoti[@"username"] isEqualToString:@"null"]) {
                        //                        str1 = dicNoti[@"account"];
                        //                    }else {
                        //                        str1 = dicNoti[@"username"];
                        //                    }
                        //                    [muAryTitleContent replaceObjectAtIndex:3 withObject:str1];
                        [_dataDict setObject:dicc[@"companyIndustry"] forKey:@"companyIndustry"];
                        [self.tableView reloadData];
                    }
                        break;
                    case 6://公司规模
                    {
                        [_dataDict setObject:dicc[@"companyScale"] forKey:@"companyScale"];
                        [self.tableView reloadData];
                    }
                        break;
                    case 7://公司地址
                    {
                        [_dataDict setObject:dicc[@"address"] forKey:@"address"];
                        [self.tableView reloadData];
                    }
                        break;
                    case 8://关注领域
                    {
                        [_dataDict setObject:dicc[@"companyField"] forKey:@"companyField"];
                        [self.tableView reloadData];
                    }
                        break;
                        
                    case 9://商务需求
                    {
                        [_dataDict setObject:dicc[@"companyBusNeeds"] forKey:@"companyBusNeeds"];
                        [self.tableView reloadData];
                    }
                        break;
                        
                    case 10://公司网址
                    {
                        [_dataDict setObject:dicc[@"companyWWW"] forKey:@"companyWWW"];
                        [self.tableView reloadData];
                    }
                        break;
                        

                    default:
                        break;
                }

                
                
            }
            
            //刷新缓存
            RCUserInfo *userInfo = [RCUserInfo new];
            userInfo.userId = [USER_DEFAULTS objectForKey:@"account"];
            userInfo.name = _dataDict[@"userName"];
            userInfo.portraitUri = self.dataDict[@"headPhoto"];
            [[RCIM sharedRCIM] refreshUserInfoCache:userInfo
                                         withUserId:userInfo.userId];
            
            [self hideBubble];
            
        }else {

            [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

        [self showErrorWithTitle:@"1" autoCloseTime:2];

    }];
}

-(BOOL)isValidateEmail:(NSString *)email {
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [emailTest evaluateWithObject:email];
}

-(void)title:(NSString *)title placeholedr:(NSString *)placeholedr key:(NSString *)key type:(NSInteger)type{
    
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    UITextField *nameField = [alert textFieldAtIndex:0];
    nameField.placeholder = placeholedr;
    
    if ([title isEqualToString:@"年龄"] || [title isEqualToString:@"联系电话"] ) {
        nameField.keyboardType = UIKeyboardTypePhonePad;
    }
    
    
    [alert showAlertWithCompletionHandler:^(NSInteger buttonIndex) {
        if(buttonIndex == 1){
            UITextField *tf=[alert textFieldAtIndex:0];
            if (tf.text.length > 0) {
                
                if ([title isEqualToString:@"邮箱地址"]) {
                    if (tf.text.length > 0 && [self isValidateEmail:tf.text] == YES) {
                        //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
                        NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
                        [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
                        [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
                        [muDicParameters setObject:tf.text forKey:key];//资源类型
                        
                        
                        [self startEditeUserInfoWithDic:muDicParameters withType:type];
                        
                    }else{

                        [self showSingleIconBubble:@"邮箱格式不正确"];
                        
                    }
                }else if([title isEqualToString:@"联系电话"]){
                    if (tf.text.length == 11) {
                        
                        NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
                        [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
                        [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
                        [muDicParameters setObject:tf.text forKey:key];//资源类型
                        
                        
                        [self startEditeUserInfoWithDic:muDicParameters withType:type];
                    }else{

                        [self showSingleIconBubble:@"手机号码不正确"];
                    
                    }
                }else{
                //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
                NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
                [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
                [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
                [muDicParameters setObject:tf.text forKey:key];//资源类型
                
                [self startEditeUserInfoWithDic:muDicParameters withType:type];
            }
        }
    }
}];
}
#pragma mark - 设置隶属组织
- (void)setLiShuZuzhi:(NSNotification *)dic
{
    dicNoti = [NSMutableDictionary dictionaryWithDictionary:dic.userInfo];//通过这个获取到传递的对象
    
    //token=rE3F2m8AvfC7CVh85O9q&userId=用户id&userName=用户名称&introduction=简介&address=地区&mobile=联系电话&shipUserId=上属公司id
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:dicNoti[@"userId"] forKey:@"shipUserId"];//上属用户id
    [muDicParameters setObject:dicNoti[@"userType"] forKey:@"shipUserType"];
    
    [self startEditeUserInfoWithDic:muDicParameters withType:4];
}
@end
